<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="/common/common.jspf"%>
<script type="text/javascript" src="${ctx}/js/mater_purcha/mater_purcha_add.js"></script>
<style type="text/css">
.col-sm-3 {
	width: 15%;
	float: left;
}

.col-sm-9 {
	width: 85%;
	float: left;
}

label[class^="btn btn-default"] {
	margin-top: -4px;
}
</style>
<script type="text/javascript" src="${ctx}/js/jedate/jedate.js"></script>
</head>
<body>
	<div class="l_err" style="width: 100%; margin-top: 2px;"></div>
	<form id="form" name="form" class="form-horizontal" method="post"
		action="${ctx}/purcha/pur_addEntity.shtml">
		<input type="hidden" class="form-control checkacc" value="${before.id}"
			name="suppFilleFromMap.id" id="id">
		<section class="panel panel-default">
		<div class="panel-body">
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-sm-3 control-label">申请部门：</label>
					<div class="col-sm-9">
					<select  class="form-control" id="client" name="purchaseFromMap.departmentId">
							<c:forEach var="key" items="${dep}" >
								<option value="${key.id}" ${key.id==before.departmentId?'selected':'' }>${key.name }</option>	
							</c:forEach>
						</select>
					</div>
				</div>
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<label class="col-sm-3 control-label">采购合同编号</label>
				<div class="col-sm-9">
					<input type="text" class="form-control checkName"
						placeholder="请输入采购合同编号" name="purchaseFromMap.purchaseNo"
						id="purchaseNo" >
				</div>
			</div>
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<label class="col-sm-3 control-label">服务等级</label>
				<div class="col-sm-9">
					
					<input type="text" class="form-control checkName"
						placeholder="请输入服务等级" name="purchaseFromMap.gradeService"
						id="gradeService" value="${before.gradeService}" >
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">备注</label>
				<div class="col-sm-9">
					<input type="text" class="form-control checkName"
						placeholder="请输入备注" name="purchaseFromMap.remark"
						id="materialNo" value="${before.remark}" >
				</div>
			</div>
			<!-- 开始处理清单 -->
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="panel panel-default">
				<div class="panel-heading">
					<h3 class="panel-title">供应商信息</h3>
				</div>
				<div class="panel-body">
					<table class="table table-bordered">
						<thead>
							<tr>
								<th style="text-align: center;width:176px;">供应商编码</th>
								<th style="text-align: center;width:176px;">供应商名称</th>
								<th style="text-align: center;width:176px;">采购编码</th>
								<th style="text-align: center;width:176px;">物料编码</th>
								<th style="text-align: center;width:135px;">单价</th>
								<th style="text-align: center;width:135px;">数量</th>
								<th style="text-align: center;"><input type="button"
									class="btn btn-primary" onclick="insert_row(this)" value="增加"></th>
								<th style="text-align: center;"><input type="button"
									class="btn btn-danger" onclick="deleteRow(this)" value="删除"></th>
						</thead>
						<tbody id="tbl">
						</tbody>
					</table>
				</div>
			</div>
			
		</div>
		<footer class="panel-footer text-right bg-light lter">
		<button type="submit" class="btn btn-success btn-s-xs">提交</button>
		</footer> </section>
	</form>
	<script type="text/javascript">
		var i = 0
		function insert_row(obj) {
			i++;
			R = tbl.insertRow(tbl.rows.length);
			C = R.insertCell(0);
			C.innerHTML = '<div class="input-group"><input type="text" class="form-control"  name="perpor1"></div>';
			C = R.insertCell(1);
			C.innerHTML = '<div class="input-group"><input type="text" class="form-control"name="perpor2"></div>';
			C = R.insertCell(2);
			C.innerHTML = '<div class="input-group"><input type="text" class="form-control"name="perpor3" id="perpor3"></div>';
			C = R.insertCell(3);
			C.innerHTML = '<div class="input-group"><input type="text" class="form-control"  name="perpor4"></div>';
			C = R.insertCell(4);
			C.innerHTML = '<div class="input-group"><input type="text" class="form-control"name="perpor5"></div>';
			C = R.insertCell(5);
			C.innerHTML = '<div class="input-group"><input type="text" class="form-control"name="perpor6"></div>';
			C = R.insertCell(6);
			C.innerHTML = '<input type="button" class="btn btn-primary" onclick ="insert_row(this)" value = "增加">';
			C = R.insertCell(7);
			C.innerHTML = '<input type="button" class="btn btn-danger" onclick ="deleteRow(this)" value ="删除">';
		}
		function deleteRow(obj) {
			var i = obj.parentNode.parentNode.rowIndex;
			if (i > 0) {
				tbl.deleteRow(i-1);
			}
		}
	</script>

<script type="text/javascript">
jeDate({
	dateCell:"#receiving_date",
	format:"YYYY-MM-DD hh:mm:ss",
	isinitVal:false,
	isTime:true, 
	isClear:false,
	minDate:"2014-09-19 00:00:00"
})
jeDate({
	dateCell:"#dateinfo",
	format:"YYYY-MM-DD hh:mm:ss",
	isinitVal:false,
	isTime:true, 
	isClear:false,
	minDate:"2014-09-19 00:00:00"
})
jeDate({
	dateCell:"#shipping_time",
	format:"YYYY-MM-DD hh:mm:ss",
	isinitVal:false,
	isTime:true, 
	isClear:false,
	minDate:"2014-09-19 00:00:00"
})
jeDate({
	dateCell:"#production_date",
	format:"YYYY-MM-DD hh:mm:ss",
	isinitVal:false,
	isTime:true, 
	isClear:false,
	minDate:"2014-09-19 00:00:00"
})
</script>
<script type="text/javascript">
//总价随着商品的数量改变而改变
$(function() {
		$("#count").change(function() {
			var unitPrice = $("#newprice").val();
			var count = $("#count").val();
			var total = $("#total").val();
			$("#total").val(unitPrice*count);
		});
	});
$(function() {
	$("#purchaseNo").change(function() {
		var purchaseNo = $("#purchaseNo").val();
		$("#perpor3").val(purchaseNo);
	});
});
</script>
</body>
</html>